﻿﻿<?php
if(get_theme_option('featured_posts') != '') {
?>
<script type="text/javascript">
var refreshActu;
$(document).ready(function() {		
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	refreshActu = setInterval('gallery()',6000);
	
}

function nextActu(){
clearInterval(refreshActu);
gallery();
refreshActu = setInterval('gallery()',5000);
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '110px'},500 );
	
	//Display the content
	$('#gallery .actu-description').html(caption);
	
	
}
</script>

<style type="text/css">
body {
	font-family: arial
}

.clear {
	clear: both
}

#gallery {
	position: relative;
	height: 380px;
	width: 610px;
	-moz-box-shadow:  -1px 2px 6px #000;
	-webkit-box-shadow:  -1px 2px 6px #000;
	box-shadow:  -1px 2px 6px #000;
}

#gallery a {
	float: left;
	position: absolute;
}

#gallery a img {
	border: none;
}

#gallery a.show {
	z-index: 500
}

#gallery .caption {
	z-index: 600;
	background-color: #000;
	color: #ffffff;
	height: 100px;
	width: 100%;
	position: absolute;
	bottom: 0;
}

#gallery .caption .actu-description {
	margin: 5px
}

#gallery .caption .actu-description h3 {
	margin: 0;
	padding: 0;
	color: #1DCCEF;
}
</style>
		<div id="lng_gallery">
			<h2 style="margin-bottom: 2px;color:white;">
			A la une au merlan
			<div class="lng_btn" style="float:right; font-size: 12px;padding-top: 10px;margin-right: 10px;cursor: pointer;">
				<div onclick="nextActu()" style="float:right;">suivant ></div>
			</div>
			</h2>
			<div id="gallery">
				<?php
				$featured_posts_category = get_theme_option('featured_posts_category');
				if($featured_posts_category != '' && $featured_posts_category != '0') {

					 $featured_posts = get_posts("numberposts=5&&category=$featured_posts_category");
					 $i = 0;
					 foreach($featured_posts as $post) {
					 	setup_postdata($post);
					 	$get_slide_image = get_post_meta($post->ID, 'featured', true);
					 	$slide_image_full = "<img src=\"$get_slide_image\" class=\"full\" alt=\"\" />";
					 	$slide_image_thumbnail = "<img src=\"$get_slide_image\" class=\"thumbnail\" alt=\"\" />";
					 	$i++;
					  ?>
						<a href="<?php the_permalink(); ?>" <?php if($i == 1) echo 'class="show"'; ?>>
							<img src="<?php echo $get_slide_image; ?>" alt="pas d'image" width="610" height="380" title="" alt="" rel="<h3><?php the_title(); ?></h3><?php the_excerpt(); ?>"/>
						</a>
					 
					 <?php }
				} else {
					for($i = 1; $i <=5; $i++) {
						?>
							<div class="imageElement">
								<h3>This is featured post <?php echo $i; ?> title</h3>
								<p>To set your featured posts, please go to your theme options page in wp-admin. You can also disable featured posts slideshow if you don't wish to display them.</p>
								<a href="#" title="This is featured post <?php echo $i; ?>" class="open"></a> 
								<img src="<?php bloginfo('template_directory'); ?>/jdgallery/slides/<?php echo $i; ?>.jpg" class="full" alt="" /> 
								<img src="<?php bloginfo('template_directory'); ?>/jdgallery/slides/<?php echo $i; ?>.jpg" class="thumbnail" alt="" /> 
							</div>
						<?php
					}
				}
				
				?>
				<div class="caption"><div class="actu-description"></div></div>
			</div>
		</div>
			<div class="clear"></div>
﻿<?php
}
?>


		<?php if(get_theme_option('video') != '') {
			?>
		<div id="actu-video" style="height:470px">
			<div class="lng_video">
				<h2 style="margin-bottom: 2px;;color:white;">Vidéo du moment</h2>
				<object width="610" height="300" ><param name="movie" value="http://www.youtube.com/v/<?php echo get_theme_option('video'); ?>&hl=en&fs=1&rel=0&border=1"></param>
					<param name="allowFullScreen" value="true"></param>
					<param name="allowscriptaccess" value="always"></param>
					<embed src="http://www.youtube.com/v/<?php echo get_theme_option('video'); ?>&hl=en&fs=1&rel=0&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="290" height="220"></embed>
				</object>
				
			</div>
		</div>
		<div class="clear"></div>
		<?php
		}
		?>
